import java.util.*;
public class text79 {

    static class ListNode {
        int val;
        ListNode next=null;


        public ListNode(int val) {
            this.val = val;
        }
    }
    public static ListNode jian()
    {
        ListNode a=new ListNode(2);
        ListNode b=new ListNode(1);
        ListNode c=new ListNode(3);
        ListNode d=new ListNode(5);
        ListNode e=new ListNode(6);
        ListNode f=new ListNode(4);
        ListNode m=new ListNode(7);
        a.next=b;
        b.next=c;
        c.next=d;
        d.next=e;
        e.next=f;
        f.next=m;
        return a;

    }
    public static boolean isPail (ListNode head) {
        ListNode slow=head;
        ListNode fast=head;
        while(fast!=null&&fast.next!=null)
        {
            slow=slow.next;
            fast=fast.next.next;
        }
        ListNode cur=null;
        ListNode pre=null;
        while(slow!=null)
        {
            pre=slow.next;
            slow.next=cur;
            cur=slow;
            slow=pre;
        }

        ListNode left=head;
        ListNode right=cur;
        while(left!=right&&left.next!=right)
        {
            if(left.val!=right.val)
            {
                return false;
            }
            left=left.next;
            right=right.next;

        }
        if(left.next==right&&left.val!=left.next.val)
        {
            return false;

        }
        return true;


        // write code here
    }
    public static ListNode ReverseList(ListNode head) {
        if(head==null)
        {
            return null;
        }
        Stack<ListNode>c=new Stack<>();
        ListNode pre=head;
        while(pre!=null)
        {
            c.push(pre);
            pre=pre.next;

        }
        ListNode head2=c.pop();
        ListNode cur=head2;
        while(!c.isEmpty())
        {
            ListNode m=c.pop();
            cur.next=m;
            cur=m;
        }

        return head2;


    }
    public static ListNode removeNthFromEnd (ListNode head, int n) {
        if(head==null||n<0)
        {
            return null;
        }
        ListNode fast=head;
        //head=reverse(head);
        ListNode slow=head;
        while(n+1>0&&fast!=null)
        {
            fast=fast.next;
            n--;
        }
        if(n==0)
        {
            return null;
        }
        while(fast!=null)
        {
            fast=fast.next;
            slow=slow.next;
        }
        slow.next=slow.next.next;
        return head;
        // write code here
    }
    public static ListNode oddEvenList (ListNode head) {
        if(head==null||head.next==null)
        {
            return head;
        }
        ListNode pre=null;
        ListNode per=null;
        ListNode cur=null;
        ListNode cru=null;
        int count=1;
        while(head!=null)
        {
            if(count%2!=0)
            {
                if(per==null)
                {
                    pre=head;
                    per=head;

                }
                else
                {
                    per.next=head;
                    per=per.next;


                }
            }
            else
            {
                if(cru==null)
                {
                    cur=head;
                    cru=head;
                }
                else
                {
                    cru.next=head;
                    cru=cru.next;

                }
            }
            head=head.next;
            count++;
        }
        per.next=cur;
        return pre;

        // write code here
    }

    // write code here





    public static void main(String[] args) {
        ListNode m=removeNthFromEnd(jian(),2);
        //ListNode n=oddEvenList(jian());

         //boolean a=isPail(jian());
        System.out.println(1);



    }
}





